<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :rules="rules" :inline="true">
      <!--      <el-form-item label="用户" prop="username">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.username"-->
      <!--          placeholder="请输入"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          style="width: 240px"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="用户" prop="userId">
        <Fuzzy :child="fuzzyData" :on-back-parent="onParentGet"></Fuzzy>
      </el-form-item>
      <el-form-item label="币种" prop="currency">
        <el-select
          v-model="queryParams.currency"
          placeholder="请选择"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in currencyOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row>
      <el-col class="card-box">
        <el-card>
          <div slot="header">
            <span>查询结果</span>
          </div>
          <div class="el-table el-table--enable-row-hover el-table--medium">
            <table cellspacing="0" style="width: 100%" v-loading="loading">
              <tbody>
                <tr>
                  <td><div class="cell">总充值</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.depositAmount
                          ? resultParams.depositAmount
                          : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">总提现</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.withdraw ? resultParams.withdraw : "--" }}
                    </div>
                  </td>
                  <td><div class="cell">总投资</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.investAmount
                          ? resultParams.investAmount
                          : "--"
                      }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">总产出</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.fixReward ? resultParams.fixReward : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">推荐奖</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.recommendReward
                          ? resultParams.recommendReward
                          : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">管理奖</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.teamReward ? resultParams.teamReward : "--"
                      }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">平级奖</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.peerReward ? resultParams.peerReward : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">级别</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.level ? resultParams.level : "--" }}
                    </div>
                  </td>
                  <td><div class="cell">注册日期</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.userCreateTime
                          ? resultParams.userCreateTime
                          : "--"
                      }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">第一次投资日期</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.investCreateTime
                          ? resultParams.investCreateTime
                          : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">兑换</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.exchangeNum
                          ? resultParams.exchangeNum
                          : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">转入BTC数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.btcInner ? resultParams.btcInner : "--" }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">转入USDT数量</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.usdtInner ? resultParams.usdtInner : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">转入CRU数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.cruInner ? resultParams.cruInner : "--" }}
                    </div>
                  </td>
                  <td><div class="cell">转入XCH数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.xchInner ? resultParams.xchInner : "--" }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">转入BZZ数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.bzzInner ? resultParams.bzzInner : "--" }}
                    </div>
                  </td>
                  <td><div class="cell">转入PHA数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.phaInner ? resultParams.phaInner : "--" }}
                    </div>
                  </td>
                  <td><div class="cell">转出BTC数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.btcOuter ? resultParams.btcOuter : "--" }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">转出USDT数量</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.udstOuter ? resultParams.udstOuter : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">转出CRU数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.cruOuter ? resultParams.cruOuter : "--" }}
                    </div>
                  </td>
                  <td><div class="cell">转出XCH数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.xchOuter ? resultParams.xchOuter : "--" }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">转出BZZ数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.bzzOuter ? resultParams.bzzOuter : "--" }}
                    </div>
                  </td>
                  <td><div class="cell">转出PHA数量</div></td>
                  <td>
                    <div class="cell">
                      {{ resultParams.phaOuter ? resultParams.phaOuter : "--" }}
                    </div>
                  </td>
                  <td><div class="cell">账户BTC余额</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.btcBalance ? resultParams.btcBalance : "--"
                      }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">账户USDT余额</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.usdtBalance
                          ? resultParams.usdtBalance
                          : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">账户CRU余额</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.cruBalance ? resultParams.cruBalance : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">账户XCH余额</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.xchBalance ? resultParams.xchBalance : "--"
                      }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">账户BZZ余额</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.bzzBalance ? resultParams.bzzBalance : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">账户PHA余额</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.phaBalance ? resultParams.phaBalance : "--"
                      }}
                    </div>
                  </td>
                  <td><div class="cell">直推人员</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.recommendCount
                          ? resultParams.recommendCount
                          : "--"
                      }}
                    </div>
                  </td>
                </tr>
                <tr>
                  <td><div class="cell">团队人数</div></td>
                  <td>
                    <div class="cell">
                      {{
                        resultParams.teamUserCount
                          ? resultParams.teamUserCount
                          : "--"
                      }}
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { selfQuery } from "@/api/biz";
import Fuzzy from '@/components/Fuzzy'


export default {
  name: "SelfQuery",
  components: {
    Fuzzy
  },
  data () {
    return {
      loading: false,
      // 查询参数
      queryParams: {
        userId: '',   //用户Id
        currency: undefined
      },
      // 币种状态数据字典
      currencyOptions: [
        {
          dictValue: 'BTC',
          dictLabel: 'BTC'
        },
        {
          dictValue: 'USDT',
          dictLabel: 'USDT'
        },
        {
          dictValue: 'CRU',
          dictLabel: 'CRU'
        },
        {
          dictValue: 'XCH',
          dictLabel: 'XCH'
        },
        {
          dictValue: 'BZZ',
          dictLabel: 'BZZ'
        },
        {
          dictValue: 'PHA',
          dictLabel: 'PHA'
        }
      ],
      resultParams: {},
      fuzzyData: {
        echoData: [],
        echoModel: ''
      },
      rules: {
        userId: [
          { required: true, message: "请输入用户名查询", trigger: "blur" }
        ],
        currency: [
          { required: true, message: "请选择币种", trigger: "change" }
        ]
      }
    };
  },
  created () { },
  methods: {
    onParentGet (message) {
      if (message) {
        this.queryParams.userId = message
      }
    },
    /** 查询角色列表 */
    selfQuery (userId, currency) {
      this.loading = true
      selfQuery(userId, currency).then(response => {
        this.loading = false
        this.resultParams = Object.assign({}, response)
      });
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.$refs["queryForm"].validate(valid => {
        if (valid) {
          this.resultParams = {}
          this.selfQuery(this.queryParams.userId, this.queryParams.currency);
        }
      });
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.resetForm("queryForm");
      this.resultParams = {}
      this.fuzzyData = {
        echoData: [],
        echoModel: ''
      }
    }
  }
};
</script>
